var express = require('express');
var router = express.Router();
var path = require('path');
var query = require('./Database');
/* GET home page. */
router.get('/', function(req, res, next) {
    res.render('Denglu', {});
});
router.post('/login',async (req,res)=>{
    // console.log(req.body);
    let login = req.body;
    console.log(login);
    let rows = await query("select * from users where phone = '"+ login.phone +"' and password = '" + login.password + "'");
    console.log('+++++++++++++++++++');
    console.log(rows[0]);
    console.log('+++++++++++++++++++');
    if (rows.length > 0){
        let data = [{code:100},rows[0]];
        res.send(data);
    }else {
        let data = [{code:0}];
        res.send(data);
    }
})
module.exports = router;